package com.yelobblog.yelobblog.controller;

import com.yelobblog.yelobblog.common.untils.Response;
import com.yelobblog.yelobblog.domain.entity.user;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import com.yelobblog.yelobblog.service.userService;
@RestController
@RequestMapping("/user")
public class userController {
    @Resource
    private userService userService;
    @PostMapping("/login")
    public Response<String> login(@RequestParam String email,@RequestParam String password) {
        // 登录逻辑
        return Response.success(userService.Login(email, password));
    }
    @PostMapping("/register")
    public Response<?> register(@RequestParam String email,@RequestParam String password,@RequestParam String code) {
        userService.Register(email, password, code);
        return Response.success();
    }
    @GetMapping("/sendCode")
    public Response<?> sendCode(@RequestParam String email) {
        userService.SendCode(email);
        return Response.success();
    }
    @GetMapping("/getSelfInfo")
    public Response<user> getSelfInfo() {
        return Response.success(userService.getSelfInfo());
    }
    @PutMapping("/updateSelfInfo")
    public Response<?> updateSelfInfo(@RequestBody user user) {
        userService.updateUserInfo(user);
        return Response.success();
    }
    @PostMapping("/follow")
    public Response<?> follow(@RequestParam Integer followId) {
        userService.follow(followId);
        return Response.success();
    }
    @PostMapping("/unfollow")
    public Response<?> unfollow(@RequestParam Integer followId) {
        userService.unfollow(followId);
        return Response.success();
    }

}
